var message
var key
var Message
var translate=""
var code=[]
var decode=[]
var information
var dekey
var code2=[]
var decode2=[]
var translate2=""


Page({
  data: {
    result1:"加密的最终结果将在这里显示",
    result2:"解密的最终结果将在这里显示"
  },
  inputvalue1: function(e)  {
    message= e.detail.value
    Message=message
 },
 inputvalue2: function(e)  {
   key= e.detail.value
},
inputvalue3: function(e)  {
  information= e.detail.value
},
encrypt: function(){
  
  for (var i = 0,len=message.length;i<len;i++)
  {
    decode.push(Number(Message.charCodeAt(i))+Number(key))
    
    
  }
 
  for (var i = 0,len=message.length;i<len;i++)
  {
    code.push(String.fromCharCode(decode[i]))
    console.log(code)
    translate+=code[i]
    console.log(translate)
    
  }
this.setData({result:translate})
},
uncrypt: function(){
  
  for (var i = 0,len=information.length;i<len;i++)
  {
    decode2.push(Number(information.charCodeAt(i))-Number(key))
    
    
  }
 
  for (var i = 0,len=information.length;i<len;i++)
  {
    code2.push(String.fromCharCode(decode2[i]))
    
    translate2+=code2[i]
    
    
  }
this.setData({result2:translate2})
},
clean: function() {
decode=[]
code=[]
translate=""
this.setData({result:""})

},
clean2: function() {
  decode2=[]
  code2=[]
  translate2=""
  this.setData({result2:""})
  
  }





})
